//package com.sinothk.server.support.exceptions;
//
//import com.sinothk.server.support.entity.ResultData;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestControllerAdvice;
//import org.springframework.web.multipart.MaxUploadSizeExceededException;
//import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
//
//@RestControllerAdvice
//@ResponseBody
//public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
//
//    @ExceptionHandler(Exception.class)
//    public ResultData<String> handleException(Exception e) {
//        e.printStackTrace();
//        return new ResultData<String>().getError(e.getMessage());//
//    }
//
//    //自定义异常
//    @ExceptionHandler(NormalException.class)
//    public ResultData<String> handleException(NormalException e) {
//        e.printStackTrace();
//        return new ResultData<String>().getError(e.getCode(), e.getMsg());
//    }
//
//    /* spring默认上传大小，超出大小捕获异常MaxUploadSizeExceededException */
//    @ExceptionHandler(MaxUploadSizeExceededException.class)
//    @ResponseBody
//    public ResultData<String> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
//        return new ResultData<String>().getError("文件大小超出限制"); //" + serverConfig.getFileMaxSize() + "
//    }
//
////    //这是实体类 参数校验注解不通过会抛出的异常 只有全局异常能拦截到
////    @ExceptionHandler(MethodArgumentNotValidException.class)
////    public ApiResult handleIllegalParamException(MethodArgumentNotValidException e) {
////        e.printStackTrace();
////        List<ObjectError> errors = e.getBindingResult().getAllErrors();
////        String message = "参数不合法";
////        if (errors.size() > 0) {
////            message = errors.get(0).getDefaultMessage();
////        }
////        ApiResult result = new ApiResult(Constants.RESP_STATUS_BADREQUEST,message);
////        return result;
////    }
//}
